<?php /*a:3:{s:64:"/www/wwwroot/pay.rym.best/application/admin/view/shop/agent.html";i:1563242530;s:65:"/www/wwwroot/pay.rym.best/application/admin/view/common/head.html";i:1563242522;s:65:"/www/wwwroot/pay.rym.best/application/admin/view/common/foot.html";i:1563242522;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo config('sys_name'); ?>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="/favicon.ico"/>  
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/common/css/font.css" media="all">
</head>
<body class="skin-<?php if(!empty($_COOKIE['skin'])){echo $_COOKIE['skin'];}else{echo '0';setcookie('skin','0');}?>">
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>合作商户管理</legend>
    </fieldset>
    <div class="demoTable">
        <div class="layui-inline">
            <input class="layui-input" name="key" id="key" placeholder="<?php echo lang('pleaseEnter'); ?>关键字">
        </div>
        <button class="layui-btn" id="search" data-type="reload"><?php echo lang('search'); ?></button>
        <a href="<?php echo url('agent'); ?>" class="layui-btn">显示全部</a> 
        <a href="<?php echo url('add'); ?>" class="layui-btn" style="float:right;"><i class="fa fa-plus" aria-hidden="true"></i><?php echo lang('add'); ?>商户</a>
        <div style="clear: both;"></div>
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<script type="text/javascript">
layui.use(['table','form'], function() {
    var table = layui.table,form = layui.form,$ = layui.jquery; 
});
function openurl(title,url,width,height){
	layer.open({
        type: 2,
        title:title,
        shade: 0.5,
        shadeClose: true,
        area: [width,height], 
        content:url,
    });    
}
</script> 

 
<script type="text/html" id="urllink">
   <a href="{{d.url}}" target="_blank">访问网站</a>
</script> 
<script type="text/html" id="lvte">
   {{d.lv}} %
</script>
<script type="text/html" id="open">
    <input type="checkbox" name="open" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="open" {{ d.open == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="action">
    <a href="<?php echo url('seller/index/index'); ?>?asid={{d.id}}" target="_blank" class="layui-btn layui-btn-xs">登录</a>
    <a href="<?php echo url('edit'); ?>?id={{d.id}}" class="layui-btn layui-btn-xs">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="channel"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="channellist">码商通道</div></script>  
<script type="text/html" id="order"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="orderlist">订单明细</div></script>  
<script type="text/html" id="jiesuan"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="jiesuanlist">结算明细</div></script>  
<script type="text/html" id="ashoplist"><div class="layui-btn layui-btn-primary layui-btn-xs" lay-event="ashoplist">下级商户</div></script>  
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;
        var tableIn = table.render({
            id: 'ad',
            elem: '#list',
            url: '<?php echo url("agent"); ?>',
            method: 'post',
            page:true,
            cols: [[
                // {checkbox: true, fixed: true},
                {field: 'id', title: 'ID',align: 'center', width: 50, fixed: true},
                {field: 'name', title: '商户名称',align: 'center',width:158,fixed: true},
                {field: 'appid', title: 'APPID',align: 'center',width:100,fixed: true}, 
                {field: 'lv', title: '手续费', align: 'center', width:150,fixed: true,templet: '#lvte'},
                {field: 'username', title: '商户联系人', align: 'center', width:120,},
                {field: 'mobile', title: '联系方式', align: 'center', width:130},
                {title: '下级商户', align: 'center',width: 100,templet: '#ashoplist'}, 
                // {field: 'channels', title: '码商通道',align: 'center', width: 100,templet: '#channel'}, 
                {field: 'orders', title: '所有订单', align: 'center',width: 100,templet: '#order'}, 
                // {title: '结算明细', align: 'center',width: 100,templet: '#jiesuan'}, 
                // {field: 'url', title: '链接', align: 'center',width: 100,templet: '#urllink'},
                {field: 'content', title: '简介',width:280,hide:true}, 
                {field: 'addtime', title: '<?php echo lang("add"); ?><?php echo lang("time"); ?>',width: 150}, 
                {field: 'balance', align: 'center',title: '余额',width: 120}, 
                {field: 'open', align: 'center', title: '<?php echo lang("status"); ?>', width: 100, toolbar: '#open'},
                {width: 160, align: 'center', toolbar: '#action'}
            ]],
            limit:60
        });
        // form.on('switch(open)', function(obj){
        //     loading =layer.load(1, {shade: [0.1,'#fff']});
        //     var id = this.value;
        //     var open = obj.elem.checked===true?1:0;
        //     $.post('<?php echo url("editState"); ?>',{'id':id,'open':open},function (res) {
        //         layer.close(loading);
        //         if (res.status==1) {
        //             layer.msg(res.msg,{time:1000,icon:1},function(){
        //                 tableIn.reload();
        //             }); 
        //         }else{
        //             layer.msg(res.msg,{time:1000,icon:2});
        //             return false;
        //         }
        //     })
        // });
        // //搜索
        // $('#search').on('click', function () {
        //     var key = $('#key').val();
        //     if ($.trim(key) === '') {
        //         layer.msg('<?php echo lang("pleaseEnter"); ?>关键字！', {icon: 0});
        //         return;
        //     }
        //     tableIn.reload({ page: {page: 1}, where: {key: key}});
        // });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'del'){
                layer.confirm('您确定要删除吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("<?php echo url('del'); ?>",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
            if(obj.event === 'orderlist') {
                layer.open({
                    type: 2,
                    title:'订单列表',
                    shade: 0.5,
                    shadeClose: true,
                    area: ['80%', '90%'], 
                    content:"<?php echo url('order/ordermin'); ?>?shopid="+data.id,
                });    
            }
            // if(obj.event === 'channellist') {
            //     layer.open({
            //         type: 2,
            //         title:'通道列表',
            //         shade: 0.5,
            //         shadeClose: true,
            //         area: ['80%', '90%'], 
            //         content:"<?php echo url('channel/channelmin'); ?>?shopid="+data.id,
            //     });    
            // }
            // if(obj.event === 'jiesuanlist') {
            //     layer.open({
            //         type: 2,
            //         title:'结算明细',
            //         shade: 0.5,
            //         shadeClose: true,
            //         area: ['80%', '90%'], 
            //         content:"<?php echo url('order/settlementmin'); ?>?shopid="+data.id,
            //     });    
            // }
            if(obj.event === 'ashoplist') {
                layer.open({
                    type: 2,
                    title:'下级商户',
                    shade: 0.5,
                    shadeClose: true,
                    area: ['80%', '90%'], 
                    content:"<?php echo url('shop/children_shop'); ?>?agentid="+data.id,
                });    
            }
        }); 
    })
</script>